package validate

import (
	"errors"
	"github.com/gin-gonic/gin"
	"net/http"
	"unicode/utf8"
)

type ProfileReq struct {
	NickName     string `json:"nickName"`
	Birth        string `json:"birth"`
	Introduction string `json:"introduction"`
}

func UpdateUserInfo(ctx *gin.Context, req ProfileReq) error {

	if utf8.RuneCountInString(req.NickName) > 30 {
		ctx.JSON(http.StatusOK, "昵称不能大于30个字")
		return errors.New("昵称不能大于30个字")
	}

	if utf8.RuneCountInString(req.Introduction) > 200 {
		ctx.JSON(http.StatusOK, "个人简介不能大于200个字")
		return errors.New("个人简介不能大于200个字")
	}
	return nil
}
